//
//  IM_Service.h
//  SportSocial
//
//  Created by yull on 14/12/9.
//  Copyright (c) 2014年 yull. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "GCDAsyncSocket.h"
#import "im_define.h"

typedef NS_ENUM(UInt8, IMServiceStatus) {
    IMServiceStatusOffline    = 0,
    IMServiceStatusConnecting = 1,
    IMServiceStatusOnline     = 2
};

@interface IM_Service : NSObject

@property (nonatomic, strong) NSString       *strHost;
@property (nonatomic, assign) UInt16         nPort;
@property (nonatomic, assign) NSInteger      nTimeout;

@property (nonatomic, strong) NSMutableArray *arrayNet;
@property (nonatomic, strong) NSMutableData  *buffData;

@property (nonatomic, strong) GCDAsyncSocket *asyncSocket;

@property (nonatomic, strong) dispatch_queue_t  serviceQueue;


@property (nonatomic, assign) IMServiceStatus status;

@property (nonatomic, strong) dispatch_source_t heartbeatTimer;

@property (nonatomic, assign) BOOL canConnect;
@property (nonatomic, assign) BOOL isConnected;

+ (IM_Service *)instance;

- (void)connect;

- (void)prepare;

- (void)disconnectService;

@end
